package test.wordcount;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class WordCountReducer extends Reducer<Text, IntWritable, Text, Text> {

	@Override
	protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
		int sum = 0;
		Text outValue = new Text();
		
		for (IntWritable intWritable : values) {
			sum+= intWritable.get();
		}
		outValue.set(String.format("%5d", sum));
		context.write(outValue, key);
	}
	
	
}
